#pragma once


#include<QAbstractTableModel>
#include<QList>
#include"Contact.h"
#include<QModelIndex>
#include<QVariant>


class TableModel : public QAbstractTableModel
{
	Q_OBJECT

	public:
		TableModel(QObject*  parent = 0);
		TableModel(QList<Contact> contacts , QObject* parent =0 );

		int rowCount( const QModelIndex& parent) const override;
		int columnCount( const QModelIndex& parent) const override;
		QVariant data(const QModelIndex& index , int role) const override;
		QVariant headerData(int section , Qt::Orientation orientation , int role) const override;
		Qt::ItemFlags flags( const QModelIndex& index) const override;
        bool setdata(const QModelIndex& index , const QVariant& value , int role = Qt::EditRole) ;
		bool insertRows(int position , int rows , const QModelIndex& index = QModelIndex()) override;
		bool removeRows(int position , int rows , const QModelIndex& index = QModelIndex()) override;
		QList<Contact> getContacts() const;

		QList<Contact> getcontacts() const;
	private:
		QList<Contact>  contacts_;
};

